package db.fortifier;

import java.util.Set;

import db.AbstractService;
import db.nutriment.Nutriment;
import db.nutriment.NutrimentService;

public class FortifierService extends AbstractService<Fortifier> implements FortifierDAO
{
    NutrimentService nutrimentService;
    
    public void setNutrimentService(NutrimentService nutrimentService) {
        this.nutrimentService = nutrimentService;
    }
    
    public void addNutriment(Long fortifierId, Long nutrimentId) {
        Fortifier fortifier = find(fortifierId);
        Nutriment nutriment = nutrimentService.find(nutrimentId);
        fortifier.getNutriments().add(nutriment);
        insert(fortifier);
    }
    
    public void newFortifier(String name) {
        Fortifier fortifier = new Fortifier();
        fortifier.setName(name);
        insert(fortifier);
    }
    
    public Set<Nutriment> listNutriment(Long fortifierId) {
        Fortifier fortifier = find(fortifierId);
        return fortifier.getNutriments();
    }
}
